/*
 * FileInfo.java
 *
 * Created on September 20, 2006, 3:55 PM
 *
 */
package org.letva.copie.common.message;

import java.io.*;

/**
 *
 * @author Vuk Nikolic
 */
public class FileInfo implements Serializable {

	/** Creates a new instance of TransferableFile */
	public FileInfo(byte[] b, File f) {
		bytes = b;
		file = f;
		isFile = file.isFile();
		fileName = file.getName();
	}

	public void writeFile(String path) {
		try {
			OutputStream out = new FileOutputStream(path + file.getName());
			out.write(bytes);
		} catch (FileNotFoundException ex) {
			ex.printStackTrace();
		} catch (IOException ex) {
			ex.printStackTrace();
		}

	}

	public boolean isFile() {
		return isFile;
	}

	public boolean isDirectory() {
		return !isFile;
	}

	public String toString() {
		return file.toString();
	}

	public String getName() {
		return fileName;
	}

	public File getFile() {
		return file;
	}

	public byte[] getBytes() {
		return bytes;
	}
	private byte[] bytes;
	private File file;
	private boolean isFile = false;
	private String fileName = "";
	private int dirLevel = 0;
}
